Skip to content

[testbot] Add tests for date-range-utils.test.ts#831

Closed
svc-osmo-ci wants to merge 2 commits intomainfrom
testbot/20260408-0631
Closed

[testbot] Add tests for date-range-utils.test.ts#831
svc-osmo-ci wants to merge 2 commits intomainfrom
testbot/20260408-0631

Conversation

@svc-osmo-ci
Copy link
Copy Markdown
Contributor

@svc-osmo-ci svc-osmo-ci commented Apr 8, 2026

Summary

AI-generated tests targeting file(s) with low coverage.

Issue - None

Files tested

  • src/ui/src/lib/date-range-utils.test.ts

Checklist

  • I am familiar with the Contributing Guidelines
  • New or existing tests cover these changes
  • The documentation is up to date with these changes

Generated by testbot pipeline

Summary by CodeRabbit

  • Tests
    • Added a comprehensive test suite for date range parsing and presets: verifies many invalid and valid input formats, correct UTC start/end behavior for dates and datetimes (including edge rollovers), deterministic time-based assertions via a mocked current date, and confirmed preset labels/values and uniqueness.

@svc-osmo-ci svc-osmo-ci added the ai-generated AI-generated PR label Apr 8, 2026
@svc-osmo-ci svc-osmo-ci requested a review from a team as a code owner April 8, 2026 06:31
@github-actions github-actions bot added the external The author is not in @NVIDIA/osmo-dev label Apr 8, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.91%. Comparing base (df4bc8d) to head (1c69a8d).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #831      +/-   ##
==========================================
+ Coverage   42.61%   42.91%   +0.29%     
==========================================
  Files         203      203              
  Lines       27025    27025              
  Branches     7652     7652              
==========================================
+ Hits        11517    11597      +80     
+ Misses      15397    15317      -80     
  Partials      111      111              
Flag Coverage Δ
backend 44.99% <ø> (+0.14%) ⬆️
ui 21.12% <ø> (+1.82%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9c6271da-29c2-4524-8a4a-0888dad72a96

📥 Commits

Reviewing files that changed from the base of the PR and between deeed33 and 1c69a8d.

📒 Files selected for processing (1)
  • src/ui/src/lib/date-range-utils.test.ts
✅ Files skipped from review due to trivial changes (1)
  • src/ui/src/lib/date-range-utils.test.ts

📝 Walkthrough

Walkthrough

A new Vitest test suite was added at src/ui/src/lib/date-range-utils.test.ts to validate parseDateRangeValue behavior across empty, malformed, date, datetime, and ISO range inputs and to verify DATE_RANGE_PRESETS labels and generated values using fake timers set to 2026-03-15T12:00:00.000Z.

Changes

Cohort / File(s) Summary
Date Range Utilities Test Suite
src/ui/src/lib/date-range-utils.test.ts
Adds a 237-line Vitest suite that: enables fake timers and sets clock to 2026-03-15T12:00:00Z; asserts parseDateRangeValue returns null for empty/malformed/invalid inputs; verifies parsing of YYYY-MM-DD (end = next-day midnight UTC), YYYY-MM-DDTHH:mm (end +1 minute), ISO ranges with .. (date end -> next-day midnight, datetime end used as-is); tests case-insensitive preset label parsing and that DATE_RANGE_PRESETS contains exactly five unique labels with expected getValue() outputs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hopped through clocks and calendar light,
Testing ranges from dawn to night,
Presets counted, edges chased—so neat,
Every timestamp found its proper seat,
Cheers from a rabbit for tests complete!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding tests for date-range-utils. It is specific, concise, and clearly conveys that the PR introduces a new test file for the date-range-utils module.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch testbot/20260408-0631

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/ui/src/lib/date-range-utils.test.ts (1)

129-133: Tighten these tests by asserting end too.

These cases only assert start, which can miss regressions in end-boundary handling.

Proposed test-strengthening diff
       it("handles range with whitespace around dates", () => {
         const result = parseDateRangeValue(" 2026-01-01 .. 2026-01-31 ");
         expect(result).not.toBeNull();
         expect(result!.start.toISOString()).toBe("2026-01-01T00:00:00.000Z");
+        expect(result!.end.toISOString()).toBe("2026-02-01T00:00:00.000Z");
       });
@@
       it("parses preset labels case-insensitively", () => {
         const result = parseDateRangeValue("TODAY");
         expect(result).not.toBeNull();
         expect(result!.start.toISOString()).toBe("2026-03-15T00:00:00.000Z");
+        expect(result!.end.toISOString()).toBe("2026-03-16T00:00:00.000Z");
       });
@@
       it("parses mixed case preset label", () => {
         const result = parseDateRangeValue("Last 7 Days");
         expect(result).not.toBeNull();
         expect(result!.start.toISOString()).toBe("2026-03-08T00:00:00.000Z");
+        expect(result!.end.toISOString()).toBe("2026-03-16T00:00:00.000Z");
       });

Also applies to: 182-192

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/ui/src/lib/date-range-utils.test.ts` around lines 129 - 133, The test for
parseDateRangeValue only asserts the start date and should also assert the end
date to catch regressions; update the spec that calls parseDateRangeValue("
2026-01-01 .. 2026-01-31 ") to assert result!.end.toISOString() equals
"2026-01-31T00:00:00.000Z" (and similarly tighten the other test block around
lines 182-192 that uses parseDateRangeValue by adding an assertion for
result!.end.toISOString() with the expected ISO end value).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/ui/src/lib/date-range-utils.test.ts`:
- Around line 129-133: The test for parseDateRangeValue only asserts the start
date and should also assert the end date to catch regressions; update the spec
that calls parseDateRangeValue(" 2026-01-01 .. 2026-01-31 ") to assert
result!.end.toISOString() equals "2026-01-31T00:00:00.000Z" (and similarly
tighten the other test block around lines 182-192 that uses parseDateRangeValue
by adding an assertion for result!.end.toISOString() with the expected ISO end
value).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9feda9ea-8e36-4c34-9f83-34e540c492c7

📥 Commits

Reviewing files that changed from the base of the PR and between df4bc8d and deeed33.

📒 Files selected for processing (1)
  • src/ui/src/lib/date-range-utils.test.ts

@jiaenren jiaenren closed this Apr 9, 2026
@jiaenren jiaenren deleted the testbot/20260408-0631 branch April 9, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated AI-generated PR external The author is not in @NVIDIA/osmo-dev

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants